<%@page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="usgs.bip.swap.view.StateListHelper" %>
<%@ page import="usgs.bip.swap.view.DownloadHelper" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 <meta http-equiv="X-UA-Compatible" content="IE=IE7" />

	<head>
		
		<link rel="shortcut icon" type="image/ico" href="favicon.ico" />
		
		<title>State Wildlife Action Plans: Downloadable Species Lists by State</title>
		<link rel="stylesheet" type="text/css" href="./style/download.css" />

		<link rel="stylesheet" type="text/css" href="./style/demo_page.css" />
		<link rel="stylesheet" type="text/css" href="./style/demo_table_jui.css" />
		<link rel="stylesheet" type="text/css" href="./style/jquery_themes/swap-theme/jquery-ui-1.8.4.custom.css" />
		 
		
	</head>
<%
// Get state name if specified through URL
String state = "";
DownloadHelper helper = (DownloadHelper) request.getAttribute("downloadHelper");
StateListHelper stateListHelper = new StateListHelper();

if(request.getParameter("state") != null){
	
	 state = request.getParameter("state");
	 if(state != null){
		 state = state.replaceAll("'|\"", "");
		 String abbr = stateListHelper.getStateAbbreviation(state);
		 if(abbr == null){
			 state = "";
		 }
		 else {
		 	helper.setState(state);
		 }
	 }
}
 
%>

<%@ include file="/style/species_header.html" %>

		<!-- floating map filter -->
		<div id="geoMapBox" title="SGCN Species" >	
			<div id="map" ></div>	
		</div>
		
		<center>
			<!-- Species Information Box Overlay -->
			<div id="speciesInformationOverlay">
				<center>
				<div style="display:none;" id="speciesInformationPanel" style="font-size:12px;" >
					<div style="font-weight:bold;text-align:center;" >Species: <span id="scientificNameSpan"></span> 
					
						[<span id="vernacularNameSpan"></span>]
						<span style="float:right;cursor:pointer;color:#990000;" onclick="splist.CloseSpeciesInformationPanel();">[Close]</span>
					</div> 
					<div style="font-weight:bold;text-align:center;color:#990000;padding-top:5px;" id="missingSpeciesState"></div> 
					<br/> 
					<div style="margin-bottom:5px;">The following states/territories consider this species in need of greatest conservation:</div> 	
					<div id="speciesInformationLinkBox"></div> 
					<table style="width:100%;">
						<tr>
						<th  style="border-right: 1px solid #ffffff;text-align:center;">
						SWAP Status
						</th>
						<th style="text-align:center;">
						NatureServe Status
						</th>
						</tr>
						<tr>
						<td style="padding:10px;border-top: 1px solid #ffffff; border-right: 1px solid #ffffff;vertical-align:top;">
						<div id="speciesGeoMap"><img src="/style/ajax-loader-long2.gif" alt="loading..." /></div>
						</td>
						<td style="vertical-align:top;border-top: 1px solid #ffffff;padding:10px;">
						<div id="speciesNSMap" ><img src="/style/ajax-loader-long2.gif" alt="loading..." /></div>
						</td>
						</tr>
					</table>
	
				</div>
				</center>
			</div>
			<!-- Species Information Box -->		
			
		<div id="pageBlocker" class="transDiv" style="left:0;width:100%;height:700px;">
				<center>
				<div style="width:100%;text-align:center;padding-top:200px;font-weight:bold;">
				LOADING.....<br/>
				
				<img src="/style/ajax-loader.gif" alt="loading..." /> 	
				</div>				
		</div>
		<div id="mainPanel">
		    <div class="mainTitle" >
				<center>
				SWAP Species List <span id="stateName"></span>
				</center>
			</div>
			
			<div id="accordionDiv" >
			<h3><a href="#"><strong>About This Site</strong> </a></h3>
				<div>
			The Association of Fish and Wildlife Agencies has identified the need to compile 
			information from the State Wildlife Action Plans in a comparable way to facilitate 
			coordination and collaboration of conservation action between states and across regions and 
			the country.  The National Biological Information Infrastructure has built a framework to 
			compile the Species of Greatest Conservation Need from the State Wildlife Action Plans 
			submitted by each state and territory in the United States.  A process that included 
			extracting species names from the SWAPs, developing computer generated comparisons, 
			and consulting with taxonomic authorities has resulted in a list of species for each 
			state that will allow comparisons and summaries between states to occur. 
		<br/><br/>
			In undergoing this process, we understand that the state agencies are already completing revisions 
			of their SWAPs, which will introduce differences from the reported information that was used to 
			develop this tool.  We kindly ask for your feedback on your state's SGCN list and any other 
			comments or recommendations regarding the information presented here.
			Please coordinate your feedback through your 
			<a style="color:blue;text-docoration:none;" href="/data/SWAP_coordinators_20100628.pdf" target="_blank">State Wildlife Action Plan coordinators</a>, 
			and they can contact either Jean Freeney [jfreeney@usgs.gov, 865.576.7044] or Andrea Ostroff [aostroff@usgs.gov, 703.648.4070] with feedback for your state.  

			</div>
				
				<h3><a href="#"><strong>SGCN Lists By State</strong></a></h3>
				<div >
				<div style="padding-bottom:5px;">Click on any state to view and/or download the SGCN list (states in red are under review): </div>
				<%@include file="/inc/state_selector_div.html" %>
				</div>
				
				
			</div>
			
			<br/><br/>
		 
			<%
			if(state.isEmpty()){
			%>		
				 
			<%} 
			else {%>
		   <div id="speciesListTabs">
				<ul>
					<li><a href="#tabs-1"> <span id="speciesListTabContent"><%=state%> Species List </span></a></li>
					<li><a href="#tabs-2">Documentation and Downloadable File</a></li>
					<li><a href="#tabs-3">Name Changes   </a></li>
					<li><a href="#tabs-4">Not Represented in National List</a></li>
				</ul>

				<div id="tabs-1">
				<div style="font-weight:bold;" >Total Species: <span id="totalSpeciesCount"/></div>
				<div class="demo_jui" style="padding:27px;" >
					
					<table cellpadding="0" cellspacing="0" border="0" class="display" id="sgcnTBL" width="100%" style=" border-left:1px solid #addddd;border-right:1px solid #addddd;">
						<thead>
							<tr>
							<th width="5%">Map View</th>
								<th width="20%">Scientific Name</th>
								<th width="25%">Common Name</th>
								<th width="15%">Taxonomic Category</th>
								<th width="30%">States</th>
								<th width="5%">State Count</th>								
							</tr>
						</thead>
						<tbody>
							
						</tbody>
						<tfoot>
							<tr>
								<th >Map View</th>
								<th>Scientific Name</th>
								<th>Common Name</th>
								<th>Taxonomic Category</th>
								<th>States</th>
								 <th>State Count</th>
								
							</tr>

						</tfoot>
					</table>

					</div>
				</div>
				<div id="tabs-2">
						
					<ul>
						<li><strong> Source: </strong> 
						<a href="<%=helper.getSource()%>" target="_blank">View list of source documentation</a> 					
						</li>					
						<br/>
						<li> <strong> Downloadable List:</strong>  
							<a href="<%=helper.getDataFile()%>" target="_blank"> <%=state%> SGCN List [text file]</a> 
							<!-- |
							<a href="<%=helper.getExcelFile()%>" target="_blank"> <%=state%> SGCN List [excel file]</a>
							 -->
						</li>
					</ul>

				</div>
				<div id="tabs-3">
					<div style="font-weight:bold;" >Names Changed: <span id="changedSpeciesCount"/></div>
					<div class="demo_jui" style="padding:27px;" >
						<table cellpadding="0" cellspacing="0" border="0" class="display" id="sgcnChangeTBL" width="100%" style=" border-left:1px solid #addddd;border-right:1px solid #addddd;">
							<thead>
								<tr>
								
									<th width="20%">Scientific Name in <%=state%> Plan</th>
									<th width="20%">Altered Scientific Name</th>
									<th width="20%">Common Name</th>
									
									<th width="40%">Change Justification</th>
							 
									
								</tr>
							</thead>
							<tbody>
								
							</tbody>
							<tfoot>
								<tr>
									<th  >Original Scientific Name</th>
									<th  >Altered Scientific Name</th>
									<th  >Common Name</th>
									<th >Change Justification</th>
									
								</tr>

							</tfoot>
						</table>
					</div>
				</div>

				<div id="tabs-4">
					<div id="omissionExplanation">
					In order to visualize commonalities among species reported in the State Wildlife Action 
					Plans nationally, a compiled list of unique scientific names needed to be created from 
					all of the states.  Varied approaches to the development of the State Wildlife Action 
					Plans somewhat limits the ability to compile a fully comprehensive national list. 
					Therefore, there are conditions (ex. population designations, etc.) in which 
					state-reported species could not be represented in the <a style="color:blue;" href="/">national SGCN list</a>, and 
					the summary will reflect a difference in the total number of species for those states.  
					For <%=state %>, they are accounted for in the table below.  
					An empty table indicates all records are represented 
					in the <a style="color:blue;" href="/">national SGCN list</a>.
					 
					 
					
					
				
				 
					</div>
					<div class="demo_jui" style="padding:27px;" >
						<table cellpadding="0" cellspacing="0" border="0" class="display" id="sgcnOmissionTBL" width="100%" style=" border-left:1px solid #addddd;border-right:1px solid #addddd;">
							<thead>
								<tr>
								
									<th width="20%">Scientific Name </th>
									<th width="20%">Common Name</th>
									<th width="20%">Taxa</th>
									<th width="40%">Reason for Omission from National List</th>
							 
									
								</tr>
							</thead>
							<tbody>
								
							</tbody>
							<tfoot>
								<tr>
									<th  >Scientific Name</th>
									<th  >Common Name</th>
									<th  >Taxa</th>
									<th >Reason for Omission from National List</th>
									
								</tr>

							</tfoot>
						</table>
					</div>
				</div>
				
			</div>
		<br/><br/>
			<%
			}
			%>		
			 
		</div>
		 

		</center>

<%@ include file="/style/species_footer.html" %>
	 
</body>
	<script type="text/javascript"  src="http://www.google.com/jsapi"></script>
   
    <script type="text/javascript">
    google.load("feeds", "1");

	google.load("visualization", "1", {packages: ['geomap']});    
 
	</script>
	<script type="text/javascript"  src="/ext_js/jquery-1.4.2.min.js"></script>

	<script type="text/javascript"  src="/ext_js/jquery-ui-1.8.2.custom.min.js"></script>
	<script type="text/javascript" language="javascript" src="/ext_js/jquery.dataTables.min.js"></script>
	<script type="text/javascript" language="javascript" src="/ext_js/jquery.dataTables.redraw.js"></script>
	<script type="text/javascript"  src="/js/data.inc.js"></script>
	<script type="text/javascript"  src="/js/SpeciesViz.js"></script>
	<script type="text/javascript" src="/js/swap.downloadable.js"></script>
	<script type="text/javascript" >	 
			var map;
			var pchart;
			var defaultData;
			var mapData;
			var pchartData;
			var stateList = new Array();
			var taxaList = new Array();
			var stateCount = 0;
			var taxaCount = 0;
			var speciesListTable = null;
			var speciesChangeListTable = null;
			var speciesOmissionListTable = null;
			var state = '<%=state%>';
			
			var defaultDataFile = '/data/json/swap_default.json';
			var splist = new SWAPSpeciesList('speciesInformationPanel', 'scientificNameSpan', 'vernacularNameSpan', 'speciesGeoMap', 'speciesNSMap', 'speciesInformationLinkBox');
	
			
			
			$(document).ready(function() {
				//$("#geoMapBox").dialog({ autoOpen: true, height: 470, width: 440  });
				//var data = loadDefaultData();
				//drawGeoMapBasedFilter(data);
				
				$('#pageBlocker').hide();
				
				if(state == ''){
				
					$('#accordionDiv').accordion({ active: 0, autoHeight: false  });
				}
				else {
					$('#accordionDiv').accordion({ active: 1, autoHeight: false  });
					
					loadDataTable(state);
					
					$("#speciesListTabs").tabs();
				}
				
				

  
			} );
			
	</script>

</html>